<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>LLM Chatbot</title>
</head>
<body>
    <h1>流式输出</h1>
    <div id="messages"></div>
    <script>
        // 发送请求
        // html5 事件流 给他支持SSE 的地址
        // SSE Server Sent Events 服务器端推送事件
        const source = new EventSource('/sse');
        source.onmessage = function(event) {
            // console.log(event.data);
            const messages = document.getElementById('messages');
            messages.innerHTML += event.data + '<br>';
        }
    </script>
</body>
</html>